#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#     Filename @  mprocess.py
#       Author @  Huoty
#  Create date @  2015-07-14 15:41:11
#  Description @  
# *************************************************************

import os
from multiprocessing import Process

# 子进程代码
def run_proc(name):
    print type(name)
    print "Run child process %s(%s)..." % (name, os.getpid())

def run_proc2(name, msg):
    print type(name)
    print "Run child process %s(%s)..." % (name, os.getpid())
    print "Get msg: %s" % msg

def run_proc3(name, msg, kw):
    print type(name)
    print type(kw)
    print "Run child process %s(%s)..." % (name, os.getpid())

# Script starts from here

if __name__ == "__main__":
    print "Parent process %s." % os.getpid()
    #p = Process(target=run_proc, args=("test",))
    #p = Process(target=run_proc2, args=("test", "I am huoty"))
    p = Process(target=run_proc3, args=("test", "I am huoty"), kwargs = {'a':1, 'b':2})
    print "Child process will start."
    p.start()
    p.join()
    print "Child process end."
